home *** CD-ROM | disk | FTP | other *** search
- * long /* count remaining if >2 */
- * mandels(count, cr,ci, zr,zi)
- * long count, cr,ci, *zr,*zi;
- * where all but count are integers scaled by 2^-26
-
- .globl _mandels
-
- * a0 = c real
- * a1 = c imag
- * d0 = z real
- * d1 = z imag
- * a2 = count
- _mandels:
- link a6,#-4
- movem.l d1-d7/a0-a5,-(a7) * save temp registers
-
- * Fetch C Args:
- move.l 8(a6),a2 * count
- move.l 12(a6),d0 * cr
- asl.l #2, d0
- move.l d0,a0
- move.l 16(a6),d1 * ci
- asl.l #2, d1
- move.l d1, a1
-
- move.l 20(a6),a3 * *zr
- move.l (a3),d0
- asl.l #2, d0
- move.l 24(a6),a3 * *zi
- move.l (a3),d1
- asl.l #2, d1
-
- move.l a0,d0 first iteration is fast!
- move.l a1,d1
-
- loop: move.l d0, d2 * compute zr^2
- bpl lab1
- neg.l d2
- lab1 move.l d2, d4 Zh Zl
- swap d4 Zl Zh
- mulu d2, d4 Ah Al = Zh(16)*Zl(16)
- swap d2 Zl Zh
- mulu d2, d2 Bh Bl = Zh(16)*Zh(16)
- clr.w d4
- swap d4 0 Ah
- add.l d4, d2
- add.l d4, d2 Bh Bl+Ah+Ah
-
- move.l d1, d3 * compute zi^2
- bpl lab2
- neg.l d3
- lab2 move.l d3, d4
- swap d4
- mulu d3, d4 * hi*lo
- swap d3
- mulu d3, d3 * hi^2
- clr.w d4
- swap d4 * >>16
- add.l d4, d3
- add.l d4, d3
-
- move.l d2, d4 * end test (zi^2)+(zr^2)>4
- add.l d3, d4
-
- *!!! debug section
- * asr.l #1,d1
- * add.l d1,d0
- * asl.l #4,d4
- * move.l d4,d0
- * clr.w d0
- * swap d0
- * bra done1
- *!!! end debug
-
- cmp.l #$04000000, d4
- bcc done * (bhs) if >=4
-
- asl.l #4, d2 * normalize
- asl.l #4, d3
-
- exg d2, d0 * zr' = cr + zr^2 - zi^2
- add.l a0, d0 * old zr left in d2 for zi' calc
- bvs doneq * terminate here for next iter if zr>=2
- sub.l d3, d0
- bvs doneq * also if zr<=-2
-
- * compute zi'
- * d7 = sign
- clr.l d7
- tst.l d2
- bpl lab3
- neg.l d2
- not.l d7
- lab3: tst.l d1
- bpl lab4
- neg.l d1
- not.l d7
- lab4: move.l d1, d5 |Zi|
- swap d5 lsw = |Zi|.hi
- swap d2 lsw = |Zr|.hi
- mulu d2, d5 |Zr|.hi * |Zi|.hi
- move.l d1, d3 lsw = |Zi|.lo
- mulu d2, d3 |Zi|.lo * |Zr|.hi
- swap d2 lsw = |Zr|.lo
- * move.l d1, d6
- * mulu d2, d6 * d6 = d2.lo * d1.lo
- * clr.w d6
- * swap d6 * bits 32..47 of result in low word
- * add.l d6, d3
- * bcc lab5
- * add.l #$10000, d5
- lab5: swap d1 lsw = |Zi|.hi
- mulu d2, d1 |Zi|.hi * |Zr|.lo
- add.l d3, d1 (|Zi|.hi*|Zr|.lo) + (|Zi|.lo*|Zr|.hi)
- asl.l #5, d5
- moveq #11, d2 normalize and *2
- lsr.l d2, d1
- add.l d5, d1
- tst.l d7
- bpl lab7 put back sign
- neg.l d1
- lab7 add.l a1, d1
-
- subq.l #1,a2 * also terminate if iteration count expired
- move.l a2,d5
- bne loop
-
- done: move.l 20(a6),a3 * *zr
- asr.l #2, d0
- move.l d0,(a3)
- move.l 24(a6),a3 * *zi
- asr.l #2, d1
- move.l d1,(a3)
-
- move.l a2, d0 * return count as value
- done1: movem.l (a7)+,d1-d7/a0-a5 * restore temp registers
- unlk a6
- rts
-
- doneq illegal should never get here
-